home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / New Venus / src / ValueControl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-30  |  1.5 KB  |  37 lines  |  [TEXT/CWIE]

  1. /*
  2.  ***********************************************************************
  3.  *
  4.  *                            Value Control
  5.  *             Slider with a window to show the current value
  6.  *                     Behaves like a glorified integer
  7.  *
  8.  ***********************************************************************
  9.  */
  10.  
  11. #include "Dialog.h"
  12.  
  13. class ValueControl : public BasicControl
  14. {
  15.   const int small_increment;                    // Increments when the scrollbar is
  16.   const int big_increment;                        // scrolled
  17.   ModelessDialog::TextItem * show_val_item;        // Have to use pointers (sigh) due to the late binding
  18.  
  19.   virtual Boolean handle_click(void);
  20.   virtual void track_action(const int part_no);
  21.   void show_curr_value(void);                    // Show the current value of the control in a special window
  22.  
  23. public:
  24.   ValueControl(const int _big_increment = 10, const int _small_increment = 1) :
  25.      big_increment(_big_increment), small_increment(_small_increment), show_val_item(0) {}
  26.   void bind(const ModelessDialog::ControlItem& control_item,
  27.               const ModelessDialog::TextItem& value_item);        // Late constructor
  28.   ~ValueControl(void);
  29.  
  30.                                             // That's what makes a ValueControl a glorified int
  31.   operator int (void) const        { return GetControlValue(our_control()); }
  32. //  friend inline int operator = (ValueControl& vc, const short value)
  33. //                                  { SetControlValue(our_control(),value); return value; }
  34.   int get_min(void) const        { return GetControlMinimum(our_control()); }
  35.   int get_max(void) const        { return GetControlMaximum(our_control()); }
  36. };
  37.